import type { AppRouteModule } from '/@/router/types';
const IFrame = () => import('/@/views/iFrames/FrameBlank.vue');

import { LAYOUT } from '/@/router/constant';
let frameSrc = 'http://localhost:8088/ScreenDesign/index.html#/project/items';
if (process.env.NODE_ENV === 'production') {
  const loaclhostNames = window.location.href.split('/');
  // 如果配置访问url则取配置文件的
  const lowCodeUrl = sessionStorage.getItem('lowCodeUrl');
  if (lowCodeUrl) {
    frameSrc = lowCodeUrl + '/ScreenDesign/index.html#/project/items';
  } else if (loaclhostNames?.length > 0 && loaclhostNames[2]) {
    const domain = loaclhostNames[2].split(':')[0];
    frameSrc = `http://${domain}:8088/ScreenDesign/index.html#/project/items`;
  }
  console.log(frameSrc);
}

const project: AppRouteModule = {
  id: '20',
  path: '/rowCodeLarge',
  name: 'rowCodeLarge',
  component: LAYOUT,
  redirect: '/rowCodeLarge/index',

  meta: {
    hideChildrenInMenu: true,
    orderNo: 20,
    icon: 'ant-design:like-outlined',
    title: '大屏设计',
  },
  children: [
    {
      id: '20-1',
      path: 'index',
      name: 'RowCodeLargeIndex',
      component: IFrame,
      meta: {
        hideMenu: true,
        frameSrc,
        title: '大屏设计',
      },
    },
  ],
};

export default project;
